<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/21 0021
 * Time: 20:37
 */

namespace com;

use think\Log;
use think\Session;

class EncryptUtils
{
    static private $chars='abcdefghijklmnopqrstuvwxyz0123456789';

    /**
     * @param $len
     * @param $charType 0 随机，1 全字母；2 全数字；
     */
    static function rndStr($len,$char_type=0){
        $val='';

        for ($i=0;$i<$len;$i++){
            $c=null;
            $index = 0;
            if($char_type==0){
                $index = rand(0,strlen(self::$chars)-1);
            }else if($char_type==1){
                $index = rand(0,strlen(self::$chars)-11);
            }else if($char_type==2){
                $index = rand(26,strlen(self::$chars)-1);
            }

            $c = substr(self::$chars,$index,1);
            $val.=$c;
        }
        return $val;
    }

}